// mock/index.js
import mock  from 'mockjs'

export default [
    {
        url: '/api/user',
        method: 'get',
        response: () => {
            return mock({
                'list|10': [{
                    'id|+1': 1,
                    'name': '@cname',
                    'age|18-60': 1,
                    'gender|1': ['男', '女']
                }]
            })
        }
    },
    {
        url: '/api/login',
        method: 'post',
        response: (req) => {
            const { username, password } = req.body
            if (username === 'admin' && password === '123456') {
                return {
                    code: 200,
                    message: '登录成功',
                    data: {
                        token: 'mock-token'
                    }
                }
            }
            return {
                code: 401,
                message: '用户名或密码错误'
            }
        }
    },
    {
        url: '/sdf',
        method: 'post',
        response: (req) => {
            return {
                code: 200,
                message: '登录成功',
                data: {
                    token: 'mock-token'
                }
            }
        }
    },
    {
        url: '/parameter/query',
        method: 'post',
        response: (req) => {
            return {
                code: 200,
                message: 'success',
                data: {
                    total: 10,
                    'rows|10': [
                        {
                            id: '@guid',
                            name1: '@city',
                            name2: 'Critical',
                            name3: '@city',
                        },
                    ],
                },
            }
        }

    }
]